class Solution(object):
    def firstMissingPositive(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        n = len(nums)
        for i, num in enumerate(nums):
            if num > n or num <= 0:
                nums[i] = n + 1
        for num in nums:
            if 0 < abs(num) <= n:
                nums[abs(num) - 1] = -abs(nums[abs(num) - 1])
        index = 0
        while index < n:
            if nums[index] > 0:
                break
            index += 1
        return index + 1


data = Solution()
nums = [1, 2, 0]
print(data.firstMissingPositive(nums))
